{% extends "forum/forumbase.html" %}

{% comment %}
#    Copyright 2012 New Mexico EPSCoR
#
#    This file is part of Teacher's P.E.T.
#
#    Teacher's P.E.T. is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    Teacher's P.E.T. is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Teacher's P.E.T..  If not, see <http://www.gnu.org/licenses/>.
{% endcomment %}

{% load files %}

{% block title %} Send PM | {{block.super}}{% endblock title %}

{% block css %}
    {{block.super}}
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/forum.css" >
{% endblock css %}

{% block content %}
<div class="forum-send-message">
	<form action="." method="POST">{% csrf_token %}
		<table>
			<tr>
				<td class="forum-send-message-recipient-label">{{form.recipient.label}}</td><td class="forum-send-message-recipient">{{form.recipient}}</td><td>{{form.recipient.errors}}</td>
			</tr>
			<tr>
				<td class="forum-send-message-subject-label">{{form.subject.label}}</td><td class="forum-send-message-subject">{{form.subject}}</td><td>{{form.subject.errors}}</td>
			</tr>
			<tr>
				<td class="forum-send-message-message-label">{{form.message.label}}</td><td class="forum-send-message-message">{{form.message}}</td><td>{{form.message.errors}}</td>
			</tr>
			{% get_file_list for form.instance as Files %}
			{% if Files %}
			<tr>
				<td>Attachments:</td>
				<td colspan="100%">
					<span class="forum-send-message-files">
						<ul>
							{% for file in Files %}
								<li>
									<a href="{% course_url forum_download_message_attachment message_id=form.instance.id filename=file.filename %}" target="_blank">
										<img src="{{STATIC_URL}}images/files/{{file.icon}}" height="25"> {{file.title}}{% if file.extension %}.{{file.extension}}{% endif %}
									</a>{% if file.description %} - {{file.description}}{% endif %}
									<a href="{% course_url forum_delete_message_attachment message_id=form.instance.id file_id=file.id %}" class="forum-messages-button forum-messages-delete-attachment">x</a>
								</li><br>
							{% endfor %}
						</ul>
					</span>
				</td>
			</tr>
			{% endif %}
			<tr>
				<td></td>
				<td>
					<button type="submit" class="forum-entries-button" name="Send" value="Send">Send</button>
					<button type="submit" class="forum-entries-button" name="Draft" value="Draft">Save as Draft</button>
					<button type="submit" class="forum-entries-button" name="Attach" value="Attach">Edit Attachments</button>
					<a class="forum-entries-button" href="{% course_url forum_view_messages %}">Cancel</a>
					{% if form.instance.id %}
						<a class="forum-send-message-delete-button" href="{% course_url forum_delete_message message_id=form.instance.id %}" title="Delete this message"><img src="{{STATIC_URL}}images/delete.png" height="20"></a>
					{% endif %}
				</td>
			</tr>
		</table>
	</form>
</div>
{% endblock content %}